//As of right now, the class exists as a simple palindrome checker. It does not
//use the stack or queue sicne I am still confused on how to use this class with them.

public class PalindromeChecker2 
{
  
  private Stack s;
  private Queue q;
  private String filename ="";
  private MyFileReader mfr;
  
  public PalindromeChecker(String filename)
  {
    mfr = new MyFileReader(filename);
    s = new Stack();
    q = new Queue();
  }
  
  public boolean weakCompareNext()
  {
    String rawPalindrome = mfr.getNext();
    while(true) {
      //rawPalindrome contains spaces and punctuation and capitalized
      if(rawPalindrome == "quit") {
        System.out.println("End of file.");
        System.exit(0);
      }
      System.out.print("\nThe phrase to check is:\n" + rawPalindrome + "\t");
      //remove capitalization
      rawPalindrome = rawPalindrome.toUpperCase();
      //remove space
      rawPalindrome = rawPalindrome.replace(" ", "");
      //remove punctuation
      rawPalindrome = rawPalindrome.replaceAll("\\p{Punct}", "");
      
      //Turns the string into an array of characters.
      char[] str = rawPalindrome.toCharArray();
      
      //Checks to see if "quit" is the next string, and if so, stops reading lines.
      if(str[0] == 'Q' && str[1] == 'U' && str[2] == 'I' && str[3] == 'T') {
        System.out.println("End of file.");
        break;
      }
      
      //Reads through the array of characters to check to see if the word is a palindrome.
      for(int i = 1; i <= str.length; i++) {
        if(str[i - 1] != str[str.length - 1]) {
          System.out.print("false \n");
          //The word is false. This is where to add the code that will handle the string for a false word.
          break;
        }
        else {
          System.out.print("true \n");
          //The word is true. This is where to add the code that will handle the string for a true word.
          break;
        }
      }
      rawPalindrome = mfr.getNext();
    }
    return true;
  }
}
